package com.woniu.user.mapper;

import com.woniu.user.entity.UserInfo;
import com.baomidou.mybatisplus.core.mapper.BaseMapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

import java.math.BigDecimal;

/**
 * <p>
 *  Mapper 接口
 * </p>
 *
 * @author 贾玉亮
 * @since 2023-01-02
 */
public interface UserInfoMapper extends BaseMapper<UserInfo> {
    @Select("select login_password as loginPassword from user_info where user_mobile=#{userMobile} and is_deleted='0'")
    String login(String userMobile);
    @Select("select id,nick_name as nickName,avatar from user_info where user_mobile=#{mobile} and is_Deleted='0'")
    UserInfo getByMobile(String mobile);
    @Select("select pay_password as payPassword from user_info where id=#{userId} and is_deleted='0'")
    String getPayPasswordByUserId(String userId);
    @Select("select balance from user_info where id=#{userId} and is_deleted='0'")
    BigDecimal getBalanceByUserId(String fkUserId);
    @Update("update user_info set balance=#{balance},update_time=NOW() where id=#{userId} and is_deleted='0'")
    int modifyBalance(@Param("balance") BigDecimal balance,@Param("userId") String userId);
    @Select("select id,nick_name nickName,real_name realName,user_mail userMail,user_mobile userMobile,id_card idCard,status,is_authentication isAuthentication,avatar,balance,create_time createTime,update_time updateTime,available_loan_amount availableLoanAmount from user_info where user_mobile=#{mobile}")
    UserInfo getUserByMobile(String mobile);
}
